// Copyright 2009 Google Inc.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
//
// Simple interface to the exposed ffmpeg functionality.

#ifndef WIRELESS_THIRD_PARTY_FFMPEG_AVCODEC_INTERFACE_H__
#define WIRELESS_THIRD_PARTY_FFMPEG_AVCODEC_INTERFACE_H__

#ifdef FFMPEG_INTERNAL_BUILD
#define EXPORTED_METHOD __declspec(dllexport)
#else
#define EXPORTED_METHOD __declspec(dllimport)
#endif

#include "sized_types.h"

struct AVCodec;
struct AVCodecContext;
struct AVFrame;

/*
 * A simple interface to ffmpeg's avcodec functions.
 */
class AvCodecInterface {
 public:
  virtual ~AvCodecInterface() = 0;

  // These functions wrapper the avcodec_* methods.
  virtual int open(AVCodecContext* avctx, AVCodec* codec) = 0;
  virtual int close(AVCodecContext* avctx) = 0;
  virtual int decode_audio2(AVCodecContext* avctx,
                            int16_t* samples,
                            int* frame_size_ptr,
                            uint8_t* buf,
                            int buf_size) = 0;
  virtual int decode_video(AVCodecContext* avctx,
                           AVFrame* picture,
                           int* got_picture_ptr,
                           uint8_t* buf,
                           int buf_size) = 0;
  virtual AVCodec* find_decoder(int id) = 0;
  virtual void get_context_defaults2(AVCodecContext* s, int codec_type) = 0;

  // Returns a concrete implementation of this interface. The object is
  // allocated on the first call. Only one should exist at any one time;
  // subsequent calls to Instance() should return the same object.
  // This function is not thread-safe and must be protected from being called by
  // two threads simultaneously.
  static EXPORTED_METHOD AvCodecInterface* Instance();
};

#endif  // WIRELESS_THIRD_PARTY_FFMPEG_AVCODEC_INTERFACE_H__
